#ifndef DESCENT_DETAIL_SCRIPT_HPP_INCLUDED
#define DESCENT_DETAIL_SCRIPT_HPP_INCLUDED

/**
 * @file 
 */

#include <string>
#include <boost/filesystem.hpp>
#include <boost/python.hpp>

namespace fs = boost::filesystem;
namespace py = boost::python;

namespace descent {
/**
 * Python script.
 */
class script {
public:
	/**
	 * Path to a Python script file.
	 */
	explicit script(const fs::path& file);
	~script();
	/**
	 * 
	 * @param T 
	 * @param symbol 
	 * @return 
	 */
	template<typename T>
	T execute(const std::string& symbol) {
		py::object r = py::exec_file(file_.string().c_str(), global_, global_);
		py::object m = global_[symbol];
		return py::extract<T>(m());
	}
private:
	/// 
	py::object main_;
	/// 
	py::object global_;
	/// 
	fs::path file_;
};
}

#endif

